# Maintainer: Saul Ibarra Corretge <saghul@gmail.com>
# Contributor: Alexey Pavlov <alexpux@gmail.com>

_realname=pyqt-builder
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.0
pkgrel=2
pkgdesc="The PEP 517 compliant PyQt build system (mingw-w64)"
arch=('any')
license=('GPL3')
url="https://pypi.org/project/PyQt-builder/"
depemds=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-python")
source=("https://pypi.io/packages/source/P/PyQt-builder/PyQt-builder-$pkgver.tar.gz"
        001-mingw-python.patch)
sha256sums=('be7fb8436e6ffb21b7e42266f0fa4776b7d62b0c7e06c63f8a066ff90554fcdc'
            'ca05d9788ffe36ac1eed7f0fdc09892b4b045ad6396e2e66c6e97e257c8c1ce7')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-mingw-python.patch

  cd "${srcdir}"
  rm -rf python-build-${MINGW_CHOST} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MINGW_CHOST}"
}

build() {
  cd python-build-${MINGW_CHOST}
  
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}"/python-build-${MINGW_CHOST}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
